﻿@using VirtualPress.Infrastructure.Entities.Entity;
@using VirtualPress.Tool.Framework;
@using VirtualPress.Infrastructure.Entities.Enum;
@using VirtualPress.Infrastructure.HitMonitor;
@{
    ViewBag.Title = "期刊详情";
    Layout = "/Views/Shared/_Main.cshtml";
}
@{Periodical data = ViewBag.Journal;
  List<Organization> leaguer = ViewBag.JournalLeaguer;
  JournalHitPack journalHit = ViewBag.Hit;
}
<div class="container">
    <div class="row">
        <div class="span9">
            <!-- navagation -->
            <ul class="breadcrumb">
                <li><a href="/">首页</a> <span class="divider">/</span></li>
                <li><a href="/Journals/home/List">期刊</a> <span class="divider">/</span></li>
                <li><a href="/Journals/home/List/@((int)data.IndType)">@data.IndType.Mapping()</a> <span
                    class="divider">/</span></li>
                <li class="active">@data.Name</li>
            </ul>
            <div class="mini-layout">
                <!-- journal img -->
                <div class="span2">
                    <img style="width:170px;height:257px;" alt="@data.Name" src="@data.CoverImg" /></div>
                <!-- journal description -->
                <div class="span6">
                    <h4>
                        @data.Name
                        @if (!data.IsActive)
                        { <b style="color: Red;">[该期刊已停用]</b> }</h4>
                    <h5>
                        @data.Name_EN</h5>
                    <hr class="grayline01" />
                    <p>
                        @data.Introduction.PieceOfString(0, 200, "......")</p>
                    <p>
                        ISSN:
                        @if (!String.IsNullOrEmpty(data.ISSN_Online))
                        {
                            @Html.Raw(data.ISSN_Print)
                        }<br />
                        eISSN:
                        @if (!String.IsNullOrEmpty(data.ISSN_Online))
                        {
                            @Html.Raw(data.ISSN_Online)
                        }<br />
                        编辑邮箱：@data.Email<br />
                    </p>
                </div>
            </div>
            <div class="tabbable">
                <!-- Only required for left/right tabs -->
                <ul class="nav nav-tabs">
                    <li class="active"><a href="#tab1" data-toggle="tab">最新文章</a></li>
                    <li><a href="#tab2" data-toggle="tab">期刊介绍</a></li>
                    <li><a href="#tab3" data-toggle="tab">学术动态</a></li>
                    <li><a href="#tab4" data-toggle="tab">征稿启事</a></li>
                    <li><a href="#tab5" data-toggle="tab">征稿范围</a></li>
                    <li><a href="#tab6" data-toggle="tab">编委</a></li>
                    <li><a href="#tab7" data-toggle="tab">作者须知</a></li>
                </ul>
                <div class="tab-content">
                    <div class="tab-pane active" id="tab1">
                        @{PeriodicalItem journalItem = ViewBag.NewJournalItem;
                          if (journalItem != null)
                          {
                            <table class="table table-hover">
                                <thead>
                                    <tr>
                                        <th style="width: 600px;">
                                            <h4>
                                                第 @journalItem.Manuscriptcode 期</h4>
                                            @journalItem.PublishDate.ToString("D",
                                                 System.Globalization.DateTimeFormatInfo.InvariantInfo)
                                        </th>
                                        <th style="text-align: center;">
                                            下载
                                        </th>
                                    </tr>
                                </thead>
                                <tbody>
                                    @{
                              if (journalItem != null && journalItem.Articles != null
                                  && journalItem.Articles.Any())
                              {
                                  foreach (var article in journalItem.Articles)
                                  {
                                      var attechment = article.Appendix.FirstOrDefault(c => c.AttachmentStatus == VirtualPress.Infrastructure.Entities.Enum.AttachmentStatus.DingGao);
                                      var authorsList = article.ArticleAuthor.Select(c => c.AuthorName).ToList();
                                      string authors = string.Empty;
                                      for (int i = 0, len = authorsList.Count(); i < len; i++)
                                      {
                                          authors += authorsList[i];
                                          if (i != len - 1)
                                          {
                                              authors += "、";
                                          }
                                      }
                                        <tr>
                                            <td>
                                                <h5>
                                                    <a href="/manuscripts/index/@article.Id" target="_blank">@article.Title</a></h5>
                                                @article.Title_EN<br />
                                                @authors
                                                <br />
                                                Abstract Full Paper: @(attechment == null ? "" : attechment.Format)
                                                (Size: @(attechment == null ? "" : attechment.Size))
                                            </td>
                                            <td style="text-align: center">
                                                <a href="/download?token=@EncodeByBase64.Encode(new { id = attechment.Id, journal = journalItem.PeriodicalId, type = 9 }.ToJson())" title="下载" target="_blank">
                                                    <i class="icon-arrow-down"></i></a>
                                            </td>
                                        </tr>
                                  }
                              }
                                    }
                                </tbody>
                            </table>
                          }}
                    </div>
                    <div class="tab-pane" id="tab2">
                        <p>
                            @Html.Raw(data.Introduction)</p>
                    </div>
                    <div class="tab-pane" id="tab3">
                        <table class="table">
                            <thead>
                                <tr>
                                    <th style="width: 560px;">
                                    </th>
                                    <th style="text-align: right; padding-right: 20px">
                                    </th>
                                </tr>
                            </thead>
                            <tbody>
                            @{
                                List<News> news = ViewBag.News;
                                if(news != null && news.Any())
                                {
                                    foreach(var item in news)
                                    {
                                        <tr>
                                    <td style="overflow: hidden;">
                                        <a href="/journals/home/news/@item.Id?journal=@data.Id" target="_blank" title="@item.Title">@item.Title.PieceOfString(0,30,"......")</a>
                                    </td>
                                    <td style="text-align: right">
                                        @item.CreateDate.ToString("yyyy-MM-dd")
                                    </td>
                                </tr>
                                    }
                                }
                                }
                                
                            </tbody>
                        </table>
                    </div>
                    <div class="tab-pane" id="tab4">
                        @Html.Raw(data.CallForPaper)
                    </div>
                    <div class="tab-pane" id="tab5">
                        @{if (!String.IsNullOrEmpty(data.ZGFW))
                          {
                              var zgfs = data.ZGFW.Split(';');
                              for (int i = 0, len = zgfs.Length; i < len; i++)
                              {
                                  if (String.IsNullOrEmpty(zgfs[i]))
                                  {
                                      continue;
                                  }
                            <p>@Html.Raw(i + 1 + "、 " + zgfs[i])</p>
                              }
                          }
                        }
                    </div>
                    <div class="tab-pane" id="tab6">
                        <p>
                            主编：@data.Editor
                            <br />
                            @if (!String.IsNullOrEmpty(data.GJGW))
                            {
                                @Html.Raw("高级顾问：" + data.GJGW) <br />
                            }
                            @if (!String.IsNullOrEmpty(data.BSGW))
                            {
                                @Html.Raw("编审顾问：" + data.BSGW) <br />
                            }
                            主办单位：@data.ZBDW
                            <br />
                            @if (!String.IsNullOrEmpty(data.XBDW))
                            {
                                @Html.Raw("协办单位：" + data.XBDW) <br />
                            }
                            @if (!String.IsNullOrEmpty(data.CBDW))
                            {
                                @Html.Raw("出版单位：" + data.CBDW) <br />
                            }
                            @if (!String.IsNullOrEmpty(data.ZGDW))
                            {
                                @Html.Raw("主管单位：" + data.ZGDW) <br />
                            }
                            @if (!String.IsNullOrEmpty(data.ZCDW))
                            {
                                @Html.Raw("主持单位：" + data.ZCDW) <br />
                            }
                            编委会列表：@if (leaguer != null && leaguer.Any())
                                  {
                                      foreach (var item in leaguer)
                                      {@Html.Raw(item.user.NickName + " ")}
                                  }
                                  else { Html.Raw("暂无"); }
                        </p>
                    </div>
                    <div class="tab-pane" id="tab7">
                        <p>
                            @Html.Raw(data.Attention)</p>
                    </div>
                </div>
            </div>
        </div>
        <div class="span3">
            <div class="mini-layout">
                <div style="text-align: center;">
                    @if (HttpContext.Current.User.Identity.IsAuthenticated)
                    {
                        var user = new User().Find(HttpContext.Current.User.Identity.Name);
                        if (user.SystemRole == VirtualPress.Infrastructure.Entities.Enum.UserRole.Member)
                        {
                        <a href="/WorkSpace/member/Contribute?journal=@data.Id" class="btn btn-primary btn-large" style="width: 73%;">
                            我要投稿</a>
                        }
                        else
                        {
                        <a href="/Home/invalid/@data.Id" class="btn btn-primary btn-large" style="width: 73%">
                            我要投稿</a>
                        }
                    }
                    else
                    { 
                        <a href="/WorkSpace/member/Contribute?journal=@data.Id" class="btn btn-primary btn-large" style="width: 73%;">
                            我要投稿</a>
                    }
                </div>
                <div class="hspace15">
                </div>
                <div class="hspace15">
                </div>
                <div class="well" style="width: 73%; margin: auto">
                    <code>本刊下载量：<a>@journalHit.DownloadNumber</a></code>
                    <div class="hspace10">
                    </div>
                    <code>本刊访问量：<a>@journalHit.VisitNumber</a></code>
                </div>
                <div class="hspace15">
                </div>
                <div class="hspace15">
                </div>
                <div class="friendlinktop">
                    <i class="icon-folder-open"></i>资源下载
                    <hr class="flline" />
                </div>
                <div class="flinks" style="line-height: 180%">
                    @{
                        List<Download> files = ViewBag.DownloadFile;
                        if (files != null && files.Any())
                        {
                            foreach (var item in files)
                            {
                        <div>
                            <i class="icon-download"></i><a href="/download?token=@(EncodeByBase64.Encode(new VirtualPress.Portal.Web.Models.DownloadModel() { Id = item.Id, Type = 200 }.ToJson()))" target="_blank">
                                @item.Title</a></div>
                            }
                        }
                    }
                </div>
                <div class="hspace15">
                </div>
                <div class="hspace15">
                </div>
                @RenderPage("~/Views/Shared/Partial/_JournalFriendLinks.cshtml")
                <div class="hspace15">
                </div>
                <div class="hspace15">
                </div>
                @RenderPage("~/Views/Shared/Partial/_Consult.cshtml")
            </div>
        </div>
    </div>
</div>
@section tail
{
    <script type="text/javascript">
        $(function () {
            $('#lijournal').addClass('active');
        });
    </script>
}
